<?
# This file is derived from xc/programs/rgb/rgb.txt in the X11R6 X 
# Consortium distribution.  Conversion to PHP was done by 
# Lars Magne Ingebrigtsen <larsi@gnus.org>, financed by Net Fonds ASA
# <URL:http://www.netfonds.no/>.
#
# The following copyright notice applies to this file, and was taken from
# xc/RELNOTES.TXT of the same distribution.
#
# Copyright (C) 1994 X Consortium
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# 
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
# 
# X Window System is a trademark of X Consortium, Inc.
# 

# Usage:
# 
# This library provides handling colors as names or arrays of RGB triples
# transparently.  You can convert a color name to a color triple with
# the rgb_color function, but mostly one would just use the rgb_allocate
# function.  It takes two parameters -- an image and a color.  (The
# color is, of course, either a color name or an RGB triple.  The
# allocated color is returned.

$RGB=array(
"snow"=>array(255,250,250),
"ghost white"=>array(248,248,255),
"GhostWhite"=>array(248,248,255),
"white smoke"=>array(245,245,245),
"WhiteSmoke"=>array(245,245,245),
"gainsboro"=>array(220,220,220),
"floral white"=>array(255,250,240),
"FloralWhite"=>array(255,250,240),
"old lace"=>array(253,245,230),
"OldLace"=>array(253,245,230),
"linen"=>array(250,240,230),
"antique white"=>array(250,235,215),
"AntiqueWhite"=>array(250,235,215),
"papaya whip"=>array(255,239,213),
"PapayaWhip"=>array(255,239,213),
"blanched almond"=>array(255,235,205),
"BlanchedAlmond"=>array(255,235,205),
"bisque"=>array(255,228,196),
"peach puff"=>array(255,218,185),
"PeachPuff"=>array(255,218,185),
"navajo white"=>array(255,222,173),
"NavajoWhite"=>array(255,222,173),
"moccasin"=>array(255,228,181),
"cornsilk"=>array(255,248,220),
"ivory"=>array(255,255,240),
"lemon chiffon"=>array(255,250,205),
"LemonChiffon"=>array(255,250,205),
"seashell"=>array(255,245,238),
"honeydew"=>array(240,255,240),
"mint cream"=>array(245,255,250),
"MintCream"=>array(245,255,250),
"azure"=>array(240,255,255),
"alice blue"=>array(240,248,255),
"AliceBlue"=>array(240,248,255),
"lavender"=>array(230,230,250),
"lavender blush"=>array(255,240,245),
"LavenderBlush"=>array(255,240,245),
"misty rose"=>array(255,228,225),
"MistyRose"=>array(255,228,225),
"white"=>array(255,255,255),
"black"=>array(0,0,0),
"dark slate gray"=>array(47,79,79),
"DarkSlateGray"=>array(47,79,79),
"dark slate grey"=>array(47,79,79),
"DarkSlateGrey"=>array(47,79,79),
"dim gray"=>array(105,105,105),
"DimGray"=>array(105,105,105),
"dim grey"=>array(105,105,105),
"DimGrey"=>array(105,105,105),
"slate gray"=>array(112,128,144),
"SlateGray"=>array(112,128,144),
"slate grey"=>array(112,128,144),
"SlateGrey"=>array(112,128,144),
"light slate gray"=>array(119,136,153),
"LightSlateGray"=>array(119,136,153),
"light slate grey"=>array(119,136,153),
"LightSlateGrey"=>array(119,136,153),
"gray"=>array(190,190,190),
"grey"=>array(190,190,190),
"light grey"=>array(211,211,211),
"LightGrey"=>array(211,211,211),
"light gray"=>array(211,211,211),
"LightGray"=>array(211,211,211),
"midnight blue"=>array(25,25,112),
"MidnightBlue"=>array(25,25,112),
"navy"=>array(0,0,128),
"navy blue"=>array(0,0,128),
"NavyBlue"=>array(0,0,128),
"cornflower blue"=>array(100,149,237),
"CornflowerBlue"=>array(100,149,237),
"dark slate blue"=>array(72,61,139),
"DarkSlateBlue"=>array(72,61,139),
"slate blue"=>array(106,90,205),
"SlateBlue"=>array(106,90,205),
"medium slate blue"=>array(123,104,238),
"MediumSlateBlue"=>array(123,104,238),
"light slate blue"=>array(132,112,255),
"LightSlateBlue"=>array(132,112,255),
"medium blue"=>array(0,0,205),
"MediumBlue"=>array(0,0,205),
"royal blue"=>array(65,105,225),
"RoyalBlue"=>array(65,105,225),
"blue"=>array(0,0,255),
"dodger blue"=>array(30,144,255),
"DodgerBlue"=>array(30,144,255),
"deep sky blue"=>array(0,191,255),
"DeepSkyBlue"=>array(0,191,255),
"sky blue"=>array(135,206,235),
"SkyBlue"=>array(135,206,235),
"light sky blue"=>array(135,206,250),
"LightSkyBlue"=>array(135,206,250),
"steel blue"=>array(70,130,180),
"SteelBlue"=>array(70,130,180),
"light steel blue"=>array(176,196,222),
"LightSteelBlue"=>array(176,196,222),
"light blue"=>array(173,216,230),
"LightBlue"=>array(173,216,230),
"powder blue"=>array(176,224,230),
"PowderBlue"=>array(176,224,230),
"pale turquoise"=>array(175,238,238),
"PaleTurquoise"=>array(175,238,238),
"dark turquoise"=>array(0,206,209),
"DarkTurquoise"=>array(0,206,209),
"medium turquoise"=>array(72,209,204),
"MediumTurquoise"=>array(72,209,204),
"turquoise"=>array(64,224,208),
"cyan"=>array(0,255,255),
"light cyan"=>array(224,255,255),
"LightCyan"=>array(224,255,255),
"cadet blue"=>array(95,158,160),
"CadetBlue"=>array(95,158,160),
"medium aquamarine"=>array(102,205,170),
"MediumAquamarine"=>array(102,205,170),
"aquamarine"=>array(127,255,212),
"dark green"=>array(0,100,0),
"DarkGreen"=>array(0,100,0),
"dark olive green"=>array(85,107,47),
"DarkOliveGreen"=>array(85,107,47),
"dark sea green"=>array(143,188,143),
"DarkSeaGreen"=>array(143,188,143),
"sea green"=>array(46,139,87),
"SeaGreen"=>array(46,139,87),
"medium sea green"=>array(60,179,113),
"MediumSeaGreen"=>array(60,179,113),
"light sea green"=>array(32,178,170),
"LightSeaGreen"=>array(32,178,170),
"pale green"=>array(152,251,152),
"PaleGreen"=>array(152,251,152),
"spring green"=>array(0,255,127),
"SpringGreen"=>array(0,255,127),
"lawn green"=>array(124,252,0),
"LawnGreen"=>array(124,252,0),
"green"=>array(0,255,0),
"chartreuse"=>array(127,255,0),
"medium spring green"=>array(0,250,154),
"MediumSpringGreen"=>array(0,250,154),
"green yellow"=>array(173,255,47),
"GreenYellow"=>array(173,255,47),
"lime green"=>array(50,205,50),
"LimeGreen"=>array(50,205,50),
"yellow green"=>array(154,205,50),
"YellowGreen"=>array(154,205,50),
"forest green"=>array(34,139,34),
"ForestGreen"=>array(34,139,34),
"olive drab"=>array(107,142,35),
"OliveDrab"=>array(107,142,35),
"dark khaki"=>array(189,183,107),
"DarkKhaki"=>array(189,183,107),
"khaki"=>array(240,230,140),
"pale goldenrod"=>array(238,232,170),
"PaleGoldenrod"=>array(238,232,170),
"light goldenrod yellow"=>array(250,250,210),
"LightGoldenrodYellow"=>array(250,250,210),
"light yellow"=>array(255,255,224),
"LightYellow"=>array(255,255,224),
"yellow"=>array(255,255,0),
"gold"=>array(255,215,0),
"light goldenrod"=>array(238,221,130),
"LightGoldenrod"=>array(238,221,130),
"goldenrod"=>array(218,165,32),
"dark goldenrod"=>array(184,134,11),
"DarkGoldenrod"=>array(184,134,11),
"rosy brown"=>array(188,143,143),
"RosyBrown"=>array(188,143,143),
"indian red"=>array(205,92,92),
"IndianRed"=>array(205,92,92),
"saddle brown"=>array(139,69,19),
"SaddleBrown"=>array(139,69,19),
"sienna"=>array(160,82,45),
"peru"=>array(205,133,63),
"burlywood"=>array(222,184,135),
"beige"=>array(245,245,220),
"wheat"=>array(245,222,179),
"sandy brown"=>array(244,164,96),
"SandyBrown"=>array(244,164,96),
"tan"=>array(210,180,140),
"chocolate"=>array(210,105,30),
"firebrick"=>array(178,34,34),
"brown"=>array(165,42,42),
"dark salmon"=>array(233,150,122),
"DarkSalmon"=>array(233,150,122),
"salmon"=>array(250,128,114),
"light salmon"=>array(255,160,122),
"LightSalmon"=>array(255,160,122),
"orange"=>array(255,165,0),
"dark orange"=>array(255,140,0),
"DarkOrange"=>array(255,140,0),
"coral"=>array(255,127,80),
"light coral"=>array(240,128,128),
"LightCoral"=>array(240,128,128),
"tomato"=>array(255,99,71),
"orange red"=>array(255,69,0),
"OrangeRed"=>array(255,69,0),
"red"=>array(255,0,0),
"hot pink"=>array(255,105,180),
"HotPink"=>array(255,105,180),
"deep pink"=>array(255,20,147),
"DeepPink"=>array(255,20,147),
"pink"=>array(255,192,203),
"light pink"=>array(255,182,193),
"LightPink"=>array(255,182,193),
"pale violet red"=>array(219,112,147),
"PaleVioletRed"=>array(219,112,147),
"maroon"=>array(176,48,96),
"medium violet red"=>array(199,21,133),
"MediumVioletRed"=>array(199,21,133),
"violet red"=>array(208,32,144),
"VioletRed"=>array(208,32,144),
"magenta"=>array(255,0,255),
"violet"=>array(238,130,238),
"plum"=>array(221,160,221),
"orchid"=>array(218,112,214),
"medium orchid"=>array(186,85,211),
"MediumOrchid"=>array(186,85,211),
"dark orchid"=>array(153,50,204),
"DarkOrchid"=>array(153,50,204),
"dark violet"=>array(148,0,211),
"DarkViolet"=>array(148,0,211),
"blue violet"=>array(138,43,226),
"BlueViolet"=>array(138,43,226),
"purple"=>array(160,32,240),
"medium purple"=>array(147,112,219),
"MediumPurple"=>array(147,112,219),
"thistle"=>array(216,191,216),
"snow1"=>array(255,250,250),
"snow2"=>array(238,233,233),
"snow3"=>array(205,201,201),
"snow4"=>array(139,137,137),
"seashell1"=>array(255,245,238),
"seashell2"=>array(238,229,222),
"seashell3"=>array(205,197,191),
"seashell4"=>array(139,134,130),
"AntiqueWhite1"=>array(255,239,219),
"AntiqueWhite2"=>array(238,223,204),
"AntiqueWhite3"=>array(205,192,176),
"AntiqueWhite4"=>array(139,131,120),
"bisque1"=>array(255,228,196),
"bisque2"=>array(238,213,183),
"bisque3"=>array(205,183,158),
"bisque4"=>array(139,125,107),
"PeachPuff1"=>array(255,218,185),
"PeachPuff2"=>array(238,203,173),
"PeachPuff3"=>array(205,175,149),
"PeachPuff4"=>array(139,119,101),
"NavajoWhite1"=>array(255,222,173),
"NavajoWhite2"=>array(238,207,161),
"NavajoWhite3"=>array(205,179,139),
"NavajoWhite4"=>array(139,121,94),
"LemonChiffon1"=>array(255,250,205),
"LemonChiffon2"=>array(238,233,191),
"LemonChiffon3"=>array(205,201,165),
"LemonChiffon4"=>array(139,137,112),
"cornsilk1"=>array(255,248,220),
"cornsilk2"=>array(238,232,205),
"cornsilk3"=>array(205,200,177),
"cornsilk4"=>array(139,136,120),
"ivory1"=>array(255,255,240),
"ivory2"=>array(238,238,224),
"ivory3"=>array(205,205,193),
"ivory4"=>array(139,139,131),
"honeydew1"=>array(240,255,240),
"honeydew2"=>array(224,238,224),
"honeydew3"=>array(193,205,193),
"honeydew4"=>array(131,139,131),
"LavenderBlush1"=>array(255,240,245),
"LavenderBlush2"=>array(238,224,229),
"LavenderBlush3"=>array(205,193,197),
"LavenderBlush4"=>array(139,131,134),
"MistyRose1"=>array(255,228,225),
"MistyRose2"=>array(238,213,210),
"MistyRose3"=>array(205,183,181),
"MistyRose4"=>array(139,125,123),
"azure1"=>array(240,255,255),
"azure2"=>array(224,238,238),
"azure3"=>array(193,205,205),
"azure4"=>array(131,139,139),
"SlateBlue1"=>array(131,111,255),
"SlateBlue2"=>array(122,103,238),
"SlateBlue3"=>array(105,89,205),
"SlateBlue4"=>array(71,60,139),
"RoyalBlue1"=>array(72,118,255),
"RoyalBlue2"=>array(67,110,238),
"RoyalBlue3"=>array(58,95,205),
"RoyalBlue4"=>array(39,64,139),
"blue1"=>array(0,0,255),
"blue2"=>array(0,0,238),
"blue3"=>array(0,0,205),
"blue4"=>array(0,0,139),
"DodgerBlue1"=>array(30,144,255),
"DodgerBlue2"=>array(28,134,238),
"DodgerBlue3"=>array(24,116,205),
"DodgerBlue4"=>array(16,78,139),
"SteelBlue1"=>array(99,184,255),
"SteelBlue2"=>array(92,172,238),
"SteelBlue3"=>array(79,148,205),
"SteelBlue4"=>array(54,100,139),
"DeepSkyBlue1"=>array(0,191,255),
"DeepSkyBlue2"=>array(0,178,238),
"DeepSkyBlue3"=>array(0,154,205),
"DeepSkyBlue4"=>array(0,104,139),
"SkyBlue1"=>array(135,206,255),
"SkyBlue2"=>array(126,192,238),
"SkyBlue3"=>array(108,166,205),
"SkyBlue4"=>array(74,112,139),
"LightSkyBlue1"=>array(176,226,255),
"LightSkyBlue2"=>array(164,211,238),
"LightSkyBlue3"=>array(141,182,205),
"LightSkyBlue4"=>array(96,123,139),
"SlateGray1"=>array(198,226,255),
"SlateGray2"=>array(185,211,238),
"SlateGray3"=>array(159,182,205),
"SlateGray4"=>array(108,123,139),
"LightSteelBlue1"=>array(202,225,255),
"LightSteelBlue2"=>array(188,210,238),
"LightSteelBlue3"=>array(162,181,205),
"LightSteelBlue4"=>array(110,123,139),
"LightBlue1"=>array(191,239,255),
"LightBlue2"=>array(178,223,238),
"LightBlue3"=>array(154,192,205),
"LightBlue4"=>array(104,131,139),
"LightCyan1"=>array(224,255,255),
"LightCyan2"=>array(209,238,238),
"LightCyan3"=>array(180,205,205),
"LightCyan4"=>array(122,139,139),
"PaleTurquoise1"=>array(187,255,255),
"PaleTurquoise2"=>array(174,238,238),
"PaleTurquoise3"=>array(150,205,205),
"PaleTurquoise4"=>array(102,139,139),
"CadetBlue1"=>array(152,245,255),
"CadetBlue2"=>array(142,229,238),
"CadetBlue3"=>array(122,197,205),
"CadetBlue4"=>array(83,134,139),
"turquoise1"=>array(0,245,255),
"turquoise2"=>array(0,229,238),
"turquoise3"=>array(0,197,205),
"turquoise4"=>array(0,134,139),
"cyan1"=>array(0,255,255),
"cyan2"=>array(0,238,238),
"cyan3"=>array(0,205,205),
"cyan4"=>array(0,139,139),
"DarkSlateGray1"=>array(151,255,255),
"DarkSlateGray2"=>array(141,238,238),
"DarkSlateGray3"=>array(121,205,205),
"DarkSlateGray4"=>array(82,139,139),
"aquamarine1"=>array(127,255,212),
"aquamarine2"=>array(118,238,198),
"aquamarine3"=>array(102,205,170),
"aquamarine4"=>array(69,139,116),
"DarkSeaGreen1"=>array(193,255,193),
"DarkSeaGreen2"=>array(180,238,180),
"DarkSeaGreen3"=>array(155,205,155),
"DarkSeaGreen4"=>array(105,139,105),
"SeaGreen1"=>array(84,255,159),
"SeaGreen2"=>array(78,238,148),
"SeaGreen3"=>array(67,205,128),
"SeaGreen4"=>array(46,139,87),
"PaleGreen1"=>array(154,255,154),
"PaleGreen2"=>array(144,238,144),
"PaleGreen3"=>array(124,205,124),
"PaleGreen4"=>array(84,139,84),
"SpringGreen1"=>array(0,255,127),
"SpringGreen2"=>array(0,238,118),
"SpringGreen3"=>array(0,205,102),
"SpringGreen4"=>array(0,139,69),
"green1"=>array(0,255,0),
"green2"=>array(0,238,0),
"green3"=>array(0,205,0),
"green4"=>array(0,139,0),
"chartreuse1"=>array(127,255,0),
"chartreuse2"=>array(118,238,0),
"chartreuse3"=>array(102,205,0),
"chartreuse4"=>array(69,139,0),
"OliveDrab1"=>array(192,255,62),
"OliveDrab2"=>array(179,238,58),
"OliveDrab3"=>array(154,205,50),
"OliveDrab4"=>array(105,139,34),
"DarkOliveGreen1"=>array(202,255,112),
"DarkOliveGreen2"=>array(188,238,104),
"DarkOliveGreen3"=>array(162,205,90),
"DarkOliveGreen4"=>array(110,139,61),
"khaki1"=>array(255,246,143),
"khaki2"=>array(238,230,133),
"khaki3"=>array(205,198,115),
"khaki4"=>array(139,134,78),
"LightGoldenrod1"=>array(255,236,139),
"LightGoldenrod2"=>array(238,220,130),
"LightGoldenrod3"=>array(205,190,112),
"LightGoldenrod4"=>array(139,129,76),
"LightYellow1"=>array(255,255,224),
"LightYellow2"=>array(238,238,209),
"LightYellow3"=>array(205,205,180),
"LightYellow4"=>array(139,139,122),
"yellow1"=>array(255,255,0),
"yellow2"=>array(238,238,0),
"yellow3"=>array(205,205,0),
"yellow4"=>array(139,139,0),
"gold1"=>array(255,215,0),
"gold2"=>array(238,201,0),
"gold3"=>array(205,173,0),
"gold4"=>array(139,117,0),
"goldenrod1"=>array(255,193,37),
"goldenrod2"=>array(238,180,34),
"goldenrod3"=>array(205,155,29),
"goldenrod4"=>array(139,105,20),
"DarkGoldenrod1"=>array(255,185,15),
"DarkGoldenrod2"=>array(238,173,14),
"DarkGoldenrod3"=>array(205,149,12),
"DarkGoldenrod4"=>array(139,101,8),
"RosyBrown1"=>array(255,193,193),
"RosyBrown2"=>array(238,180,180),
"RosyBrown3"=>array(205,155,155),
"RosyBrown4"=>array(139,105,105),
"IndianRed1"=>array(255,106,106),
"IndianRed2"=>array(238,99,99),
"IndianRed3"=>array(205,85,85),
"IndianRed4"=>array(139,58,58),
"sienna1"=>array(255,130,71),
"sienna2"=>array(238,121,66),
"sienna3"=>array(205,104,57),
"sienna4"=>array(139,71,38),
"burlywood1"=>array(255,211,155),
"burlywood2"=>array(238,197,145),
"burlywood3"=>array(205,170,125),
"burlywood4"=>array(139,115,85),
"wheat1"=>array(255,231,186),
"wheat2"=>array(238,216,174),
"wheat3"=>array(205,186,150),
"wheat4"=>array(139,126,102),
"tan1"=>array(255,165,79),
"tan2"=>array(238,154,73),
"tan3"=>array(205,133,63),
"tan4"=>array(139,90,43),
"chocolate1"=>array(255,127,36),
"chocolate2"=>array(238,118,33),
"chocolate3"=>array(205,102,29),
"chocolate4"=>array(139,69,19),
"firebrick1"=>array(255,48,48),
"firebrick2"=>array(238,44,44),
"firebrick3"=>array(205,38,38),
"firebrick4"=>array(139,26,26),
"brown1"=>array(255,64,64),
"brown2"=>array(238,59,59),
"brown3"=>array(205,51,51),
"brown4"=>array(139,35,35),
"salmon1"=>array(255,140,105),
"salmon2"=>array(238,130,98),
"salmon3"=>array(205,112,84),
"salmon4"=>array(139,76,57),
"LightSalmon1"=>array(255,160,122),
"LightSalmon2"=>array(238,149,114),
"LightSalmon3"=>array(205,129,98),
"LightSalmon4"=>array(139,87,66),
"orange1"=>array(255,165,0),
"orange2"=>array(238,154,0),
"orange3"=>array(205,133,0),
"orange4"=>array(139,90,0),
"DarkOrange1"=>array(255,127,0),
"DarkOrange2"=>array(238,118,0),
"DarkOrange3"=>array(205,102,0),
"DarkOrange4"=>array(139,69,0),
"coral1"=>array(255,114,86),
"coral2"=>array(238,106,80),
"coral3"=>array(205,91,69),
"coral4"=>array(139,62,47),
"tomato1"=>array(255,99,71),
"tomato2"=>array(238,92,66),
"tomato3"=>array(205,79,57),
"tomato4"=>array(139,54,38),
"OrangeRed1"=>array(255,69,0),
"OrangeRed2"=>array(238,64,0),
"OrangeRed3"=>array(205,55,0),
"OrangeRed4"=>array(139,37,0),
"red1"=>array(255,0,0),
"red2"=>array(238,0,0),
"red3"=>array(205,0,0),
"red4"=>array(139,0,0),
"DeepPink1"=>array(255,20,147),
"DeepPink2"=>array(238,18,137),
"DeepPink3"=>array(205,16,118),
"DeepPink4"=>array(139,10,80),
"HotPink1"=>array(255,110,180),
"HotPink2"=>array(238,106,167),
"HotPink3"=>array(205,96,144),
"HotPink4"=>array(139,58,98),
"pink1"=>array(255,181,197),
"pink2"=>array(238,169,184),
"pink3"=>array(205,145,158),
"pink4"=>array(139,99,108),
"LightPink1"=>array(255,174,185),
"LightPink2"=>array(238,162,173),
"LightPink3"=>array(205,140,149),
"LightPink4"=>array(139,95,101),
"PaleVioletRed1"=>array(255,130,171),
"PaleVioletRed2"=>array(238,121,159),
"PaleVioletRed3"=>array(205,104,137),
"PaleVioletRed4"=>array(139,71,93),
"maroon1"=>array(255,52,179),
"maroon2"=>array(238,48,167),
"maroon3"=>array(205,41,144),
"maroon4"=>array(139,28,98),
"VioletRed1"=>array(255,62,150),
"VioletRed2"=>array(238,58,140),
"VioletRed3"=>array(205,50,120),
"VioletRed4"=>array(139,34,82),
"magenta1"=>array(255,0,255),
"magenta2"=>array(238,0,238),
"magenta3"=>array(205,0,205),
"magenta4"=>array(139,0,139),
"orchid1"=>array(255,131,250),
"orchid2"=>array(238,122,233),
"orchid3"=>array(205,105,201),
"orchid4"=>array(139,71,137),
"plum1"=>array(255,187,255),
"plum2"=>array(238,174,238),
"plum3"=>array(205,150,205),
"plum4"=>array(139,102,139),
"MediumOrchid1"=>array(224,102,255),
"MediumOrchid2"=>array(209,95,238),
"MediumOrchid3"=>array(180,82,205),
"MediumOrchid4"=>array(122,55,139),
"DarkOrchid1"=>array(191,62,255),
"DarkOrchid2"=>array(178,58,238),
"DarkOrchid3"=>array(154,50,205),
"DarkOrchid4"=>array(104,34,139),
"purple1"=>array(155,48,255),
"purple2"=>array(145,44,238),
"purple3"=>array(125,38,205),
"purple4"=>array(85,26,139),
"MediumPurple1"=>array(171,130,255),
"MediumPurple2"=>array(159,121,238),
"MediumPurple3"=>array(137,104,205),
"MediumPurple4"=>array(93,71,139),
"thistle1"=>array(255,225,255),
"thistle2"=>array(238,210,238),
"thistle3"=>array(205,181,205),
"thistle4"=>array(139,123,139),
"gray0"=>array(0,0,0),
"grey0"=>array(0,0,0),
"gray1"=>array(3,3,3),
"grey1"=>array(3,3,3),
"gray2"=>array(5,5,5),
"grey2"=>array(5,5,5),
"gray3"=>array(8,8,8),
"grey3"=>array(8,8,8),
"gray4"=>array(10,10,10),
"grey4"=>array(10,10,10),
"gray5"=>array(13,13,13),
"grey5"=>array(13,13,13),
"gray6"=>array(15,15,15),
"grey6"=>array(15,15,15),
"gray7"=>array(18,18,18),
"grey7"=>array(18,18,18),
"gray8"=>array(20,20,20),
"grey8"=>array(20,20,20),
"gray9"=>array(23,23,23),
"grey9"=>array(23,23,23),
"gray10"=>array(26,26,26),
"grey10"=>array(26,26,26),
"gray11"=>array(28,28,28),
"grey11"=>array(28,28,28),
"gray12"=>array(31,31,31),
"grey12"=>array(31,31,31),
"gray13"=>array(33,33,33),
"grey13"=>array(33,33,33),
"gray14"=>array(36,36,36),
"grey14"=>array(36,36,36),
"gray15"=>array(38,38,38),
"grey15"=>array(38,38,38),
"gray16"=>array(41,41,41),
"grey16"=>array(41,41,41),
"gray17"=>array(43,43,43),
"grey17"=>array(43,43,43),
"gray18"=>array(46,46,46),
"grey18"=>array(46,46,46),
"gray19"=>array(48,48,48),
"grey19"=>array(48,48,48),
"gray20"=>array(51,51,51),
"grey20"=>array(51,51,51),
"gray21"=>array(54,54,54),
"grey21"=>array(54,54,54),
"gray22"=>array(56,56,56),
"grey22"=>array(56,56,56),
"gray23"=>array(59,59,59),
"grey23"=>array(59,59,59),
"gray24"=>array(61,61,61),
"grey24"=>array(61,61,61),
"gray25"=>array(64,64,64),
"grey25"=>array(64,64,64),
"gray26"=>array(66,66,66),
"grey26"=>array(66,66,66),
"gray27"=>array(69,69,69),
"grey27"=>array(69,69,69),
"gray28"=>array(71,71,71),
"grey28"=>array(71,71,71),
"gray29"=>array(74,74,74),
"grey29"=>array(74,74,74),
"gray30"=>array(77,77,77),
"grey30"=>array(77,77,77),
"gray31"=>array(79,79,79),
"grey31"=>array(79,79,79),
"gray32"=>array(82,82,82),
"grey32"=>array(82,82,82),
"gray33"=>array(84,84,84),
"grey33"=>array(84,84,84),
"gray34"=>array(87,87,87),
"grey34"=>array(87,87,87),
"gray35"=>array(89,89,89),
"grey35"=>array(89,89,89),
"gray36"=>array(92,92,92),
"grey36"=>array(92,92,92),
"gray37"=>array(94,94,94),
"grey37"=>array(94,94,94),
"gray38"=>array(97,97,97),
"grey38"=>array(97,97,97),
"gray39"=>array(99,99,99),
"grey39"=>array(99,99,99),
"gray40"=>array(102,102,102),
"grey40"=>array(102,102,102),
"gray41"=>array(105,105,105),
"grey41"=>array(105,105,105),
"gray42"=>array(107,107,107),
"grey42"=>array(107,107,107),
"gray43"=>array(110,110,110),
"grey43"=>array(110,110,110),
"gray44"=>array(112,112,112),
"grey44"=>array(112,112,112),
"gray45"=>array(115,115,115),
"grey45"=>array(115,115,115),
"gray46"=>array(117,117,117),
"grey46"=>array(117,117,117),
"gray47"=>array(120,120,120),
"grey47"=>array(120,120,120),
"gray48"=>array(122,122,122),
"grey48"=>array(122,122,122),
"gray49"=>array(125,125,125),
"grey49"=>array(125,125,125),
"gray50"=>array(127,127,127),
"grey50"=>array(127,127,127),
"gray51"=>array(130,130,130),
"grey51"=>array(130,130,130),
"gray52"=>array(133,133,133),
"grey52"=>array(133,133,133),
"gray53"=>array(135,135,135),
"grey53"=>array(135,135,135),
"gray54"=>array(138,138,138),
"grey54"=>array(138,138,138),
"gray55"=>array(140,140,140),
"grey55"=>array(140,140,140),
"gray56"=>array(143,143,143),
"grey56"=>array(143,143,143),
"gray57"=>array(145,145,145),
"grey57"=>array(145,145,145),
"gray58"=>array(148,148,148),
"grey58"=>array(148,148,148),
"gray59"=>array(150,150,150),
"grey59"=>array(150,150,150),
"gray60"=>array(153,153,153),
"grey60"=>array(153,153,153),
"gray61"=>array(156,156,156),
"grey61"=>array(156,156,156),
"gray62"=>array(158,158,158),
"grey62"=>array(158,158,158),
"gray63"=>array(161,161,161),
"grey63"=>array(161,161,161),
"gray64"=>array(163,163,163),
"grey64"=>array(163,163,163),
"gray65"=>array(166,166,166),
"grey65"=>array(166,166,166),
"gray66"=>array(168,168,168),
"grey66"=>array(168,168,168),
"gray67"=>array(171,171,171),
"grey67"=>array(171,171,171),
"gray68"=>array(173,173,173),
"grey68"=>array(173,173,173),
"gray69"=>array(176,176,176),
"grey69"=>array(176,176,176),
"gray70"=>array(179,179,179),
"grey70"=>array(179,179,179),
"gray71"=>array(181,181,181),
"grey71"=>array(181,181,181),
"gray72"=>array(184,184,184),
"grey72"=>array(184,184,184),
"gray73"=>array(186,186,186),
"grey73"=>array(186,186,186),
"gray74"=>array(189,189,189),
"grey74"=>array(189,189,189),
"gray75"=>array(191,191,191),
"grey75"=>array(191,191,191),
"gray76"=>array(194,194,194),
"grey76"=>array(194,194,194),
"gray77"=>array(196,196,196),
"grey77"=>array(196,196,196),
"gray78"=>array(199,199,199),
"grey78"=>array(199,199,199),
"gray79"=>array(201,201,201),
"grey79"=>array(201,201,201),
"gray80"=>array(204,204,204),
"grey80"=>array(204,204,204),
"gray81"=>array(207,207,207),
"grey81"=>array(207,207,207),
"gray82"=>array(209,209,209),
"grey82"=>array(209,209,209),
"gray83"=>array(212,212,212),
"grey83"=>array(212,212,212),
"gray84"=>array(214,214,214),
"grey84"=>array(214,214,214),
"gray85"=>array(217,217,217),
"grey85"=>array(217,217,217),
"gray86"=>array(219,219,219),
"grey86"=>array(219,219,219),
"gray87"=>array(222,222,222),
"grey87"=>array(222,222,222),
"gray88"=>array(224,224,224),
"grey88"=>array(224,224,224),
"gray89"=>array(227,227,227),
"grey89"=>array(227,227,227),
"gray90"=>array(229,229,229),
"grey90"=>array(229,229,229),
"gray91"=>array(232,232,232),
"grey91"=>array(232,232,232),
"gray92"=>array(235,235,235),
"grey92"=>array(235,235,235),
"gray93"=>array(237,237,237),
"grey93"=>array(237,237,237),
"gray94"=>array(240,240,240),
"grey94"=>array(240,240,240),
"gray95"=>array(242,242,242),
"grey95"=>array(242,242,242),
"gray96"=>array(245,245,245),
"grey96"=>array(245,245,245),
"gray97"=>array(247,247,247),
"grey97"=>array(247,247,247),
"gray98"=>array(250,250,250),
"grey98"=>array(250,250,250),
"gray99"=>array(252,252,252),
"grey99"=>array(252,252,252),
"gray100"=>array(255,255,255),
"grey100"=>array(255,255,255),
"dark grey"=>array(169,169,169),
"DarkGrey"=>array(169,169,169),
"dark gray"=>array(169,169,169),
"DarkGray"=>array(169,169,169),
"dark blue"=>array(0,0,139),
"DarkBlue"=>array(0,0,139),
"dark cyan"=>array(0,139,139),
"DarkCyan"=>array(0,139,139),
"dark magenta"=>array(139,0,139),
"DarkMagenta"=>array(139,0,139),
"dark red"=>array(139,0,0),
"DarkRed"=>array(139,0,0),
"light green"=>array(144,238,144),
"LightGreen"=>array(144,238,144));

function rgb_color ($color) {
  global $RGB;
  if (is_string($color)) {
      if (substr($color, 0, 1) == "#") {
	  return array(hexdec(substr($color, 1, 2)), 
		       hexdec(substr($color, 3, 2)),
		       hexdec(substr($color, 5, 2)));
      } else {
	  return $RGB[$color];
      }
  } else {
      return $color;
  }
}

function rgb_allocate ($image, $color) {
  list ($r, $g, $b) = rgb_color($color);
  $index = imagecolorexact($image, $r, $g, $b);
  if ($index == -1) {
      return imagecolorallocate($image, $r, $g, $b);
  } else {
      return $index;
  }
}

function rgb_gradient_color ($from, $to, $numcols) {
    $fcol = rgb_color($from);
    $tcol = rgb_color($to);

    $rfactor = ($tcol[0]-$fcol[0]) / $numcols;
    $gfactor = ($tcol[1]-$fcol[1]) / $numcols;
    $bfactor = ($tcol[2]-$fcol[2]) / $numcols;

    for ($i = 0; $i < $numcols; $i++) {
	$rnum = floor($fcol[0] + $i * $rfactor);
	$gnum = floor($fcol[1] + $i * $gfactor);
	$bnum = floor($fcol[2] + $i * $bfactor);

	$colors[$i] = sprintf("#%02x%02x%02x", $rnum, $gnum, $bnum);
    }
    return ($colors);
}

function rgb_allocate_colors ($im, $colors) {
    for ($i = 0; $i<sizeof($colors); $i++) {
	$colors[$i]= rgb_allocate($im, $colors[$i]);
    }
    return $colors;
}

?>
